namespace Digitalmes.Domain.Entities.Mes.Equipments;

/// <summary>
/// 设备点检计划表。
/// </summary>
[SugarTable("equip_inspection_plan")]
public sealed class EquipInspectionPlan : AuditedEntity
{
    /// <summary>
    /// 关联的设备 Id
    /// </summary>
    public long MachineryId { get; set; }

    /// <summary>
    /// 关联的设备
    /// </summary>
    [Navigate(NavigateType.OneToOne, nameof(MachineryId))]
    public EquipMachinery? Machinery { get; set; }

    /// <summary>
    /// 点检计划名称
    /// </summary>
    public string? PlanName { get; set; }

    /// <summary>
    /// 点检类型（手动/自动）
    /// </summary>
    [SugarColumn(SqlParameterDbType = typeof(EnumToStringConvert))]
    public InspectTypeEnum InspectType { get; set; }

    /// <summary>
    /// 设备手动点检项目集合
    /// </summary>
    [Navigate(NavigateType.OneToMany, nameof(EquipManualInspectionItem.PlanId))]
    public List<EquipManualInspectionItem>? ManualInspectionItems { get; set; }

    /// <summary>
    /// 设备自动点检项目集合
    /// </summary>
    [Navigate(NavigateType.OneToMany, nameof(EquipAutoInspectionItem.PlanId))]
    public List<EquipAutoInspectionItem>? AutoInspectionItems { get; set; }

    /// <summary>
    /// 执行计划（可以为任意时间点检，也可以为定时点检，如每周几的某时、每天的某时、每天第一班、每班等）
    /// </summary>
    public string? Schedule { get; set; }

    /// <summary>
    /// 到时间未点检时提醒方式，1->提醒、2->警告、3->终止运行
    /// </summary>
    public int Remind { get; set; }

    /// <summary>
    /// 是否根据点检项来判定最终结果
    /// </summary>
    /// <remarks>
    /// 设置后将根据每项点检结果来判定此次点检的最终结果。
    /// </remarks>
    public bool IsCheckFinalResult { get; set; }

    /// <summary>
    /// 启用状态（0->停用，1->启用）
    /// </summary>
    public EnabledStatusEnum Status { get; set; }

    /// <summary>
    /// 备注
    /// </summary>
    public string? Remark { get; set; }
}
